package com.jing.ads.view;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.jing.ads.R;
import com.jing.ads.activity.ActivityMain;

public class HandlerView extends LinearLayout {

	private Context context;
	private ImageView syncImg;
	
	public HandlerView(Context context) {
		this(context, null);
	}

	public HandlerView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context = context;
		this.setClickable(false);
		init();
	}

	private void init() {
		View view = LayoutInflater.from(context).inflate(R.layout.handler, null);
		this.addView(view);
		syncImg = (ImageView) view.findViewById(R.id.sync_img);
//		view.findViewById(R.id.sync_img).setOnClickListener(new View.OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//				Intent i = new Intent(context, ActivityMain.class);
//				i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//				context.startActivity(i);
//			}
//		});
		Handler h = new Handler();
		h.postDelayed(new Runnable() {
			
			@Override
			public void run() {
				((AnimationDrawable)syncImg.getDrawable()).start();
			}
		}, 500);
	}
}
